package leetcode;

import java.util.Scanner;

/**
 * ClassName: BaiduT1
 * Package: leetcode
 * Description:
 *
 * @Author wjn
 * @Create 2025/9/2 19:19
 * @Version 1.0
 */
public class HuaweiT2 {

    private static String N_STR;
    private static int LEN;
    private static boolean[] isPrime;
    private static final StringBuilder ansBuilder = new StringBuilder();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        sc.close();

        N_STR = String.valueOf(n);
        LEN = N_STR.length();

        siece(18 * 9);

        if (dfs(0, 0, 0, false)) {
            System.out.println(ansBuilder.toString());
        } else {
            String shorterAns = findMaxShorter();
            System.out.println(
                    shorterAns != null ? shorterAns : "-1"
            );
        }

    }

    private static String findMaxShorter() {
    }

    private static boolean dfs(int index, int sum, int lastDigit, boolean isLess) {
        if (index == LEN) {
            return sum > 1 && isPrime[sum];
        }

        int limit = isLess ? 9 : N_STR.charAt(index) - '0';
        for (int d = limit; d >= lastDigit; d--) {
            if (index == 0 && d == 0 && LEN > 1 ) {
                continue;
            }



        }
    }

    private static void siece(int i) {
    }

}
